package ru.spb.osll.myfit.server.parser;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import ru.spb.osll.myfit.common.Table;
import ru.spb.osll.myfit.common.TableStyle;
import ru.spb.osll.myfit.fixtures.base.DummyOneLineFixture;
import ru.spb.osll.myfit.server.Converter;
import fitlibrary.DoFixture;
import fitlibrary.SetUpFixture;

public class TableUtilsTest {
	private PageParser m_parser = new PageParser(new Converter());

	@Test
	public void testTableToString() {
		Table table = m_parser.createTable(TableStyle.ONE_LINE_FIXTIRE,
				"enable advanced retention on clusters");
		assertEquals("|enable advanced retention on clusters|"
				+ PageParser.LINE_SEPARATOR, PageParserUtils
				.tableToString(table));
		table = m_parser.createTable(TableStyle.DO_FIXTURE, "with cubetools",
				PageParser.LINE_SEPARATOR, "write", "10", "files of size",
				"10KB", "using", "10", "threads");
		assertEquals("|with cubetools|" + PageParser.LINE_SEPARATOR
				+ "|write|10|files of size|10KB|using|10|threads|"
				+ PageParser.LINE_SEPARATOR, PageParserUtils
				.tableToString(table));
	}

	private static class DummyDoFixture extends DoFixture {
	}

	private static class DummySetUpFixture extends SetUpFixture {
	}

	@Test
	public void testGetTableStyle() {
		assertEquals(TableStyle.ONE_LINE_FIXTIRE, PageParserUtils
				.getTableStyle(DummyOneLineFixture.class));
		assertEquals(TableStyle.DO_FIXTURE, PageParserUtils
				.getTableStyle(DummyDoFixture.class));
		assertEquals(TableStyle.SETUP_FIXTURE, PageParserUtils
				.getTableStyle(DummySetUpFixture.class));
	}

}
